using System;
using UnityEngine;

namespace BitMango
{
	public static class TransformExt
	{
		public static T GetChildComponentNamed<T>(this Transform parent, string path) where T : Component
		{
			Transform transform = parent.Find(path);
			if (transform != null)
			{
				return transform.GetComponent<T>();
			}
			return (T)((object)null);
		}

		public static void SetLocalPositionXY(this Transform tr, float x, float y)
		{
			tr.localPosition = new Vector3(x, y, tr.localPosition.z);
		}

		public static void AddLocalPositionX(this Transform tr, float x)
		{
			Vector3 localPosition = tr.localPosition;
			localPosition.x += x;
			tr.localPosition = localPosition;
		}

		public static void AddLocalPositionY(this Transform tr, float y)
		{
			Vector3 localPosition = tr.localPosition;
			localPosition.y += y;
			tr.localPosition = localPosition;
		}

		public static void AddLocalPositionZ(this Transform tr, float z)
		{
			Vector3 localPosition = tr.localPosition;
			localPosition.z += z;
			tr.localPosition = localPosition;
		}

		public static void SetLocalPositionX(this Transform tr, float x)
		{
			Vector3 localPosition = tr.localPosition;
			localPosition.x = x;
			tr.localPosition = localPosition;
		}

		public static void SetLocalPositionY(this Transform tr, float y)
		{
			Vector3 localPosition = tr.localPosition;
			localPosition.y = y;
			tr.localPosition = localPosition;
		}

		public static void SetLocalPositionZ(this Transform tr, float z)
		{
			Vector3 localPosition = tr.localPosition;
			localPosition.z = z;
			tr.localPosition = localPosition;
		}

		public static void SetLocalScaleXY(this Transform tr, float x, float y)
		{
			tr.localScale = new Vector3(x, y, tr.localScale.z);
		}
	}
}
